import React, { Component } from "react";
import { connect } from "react-redux";
import { incremented, decremented } from "../store";

class CounterClass extends Component {
  render() {
    const { value, incremented, decremented } = this.props;
    return (
      <div>
        <p>当前值: {value}</p>
        <button onClick={incremented}>+1</button>
        <button onClick={decremented}>-1</button>
      </div>
    );
  }
}

const mapStateToProps = (state) => ({
  value: state.counter.value,
});

const mapDispatchToProps = {
  incremented,
  decremented,
};

export default connect(mapStateToProps, mapDispatchToProps)(CounterClass);
